package com.scau.clothes.api.sale;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.scau.clothes.core.core.entity.AjaxResult;
import com.scau.clothes.sale.model.entity.SaleClothes;
import com.scau.clothes.sale.service.SaleClothesService;
import com.scau.clothes.sale.service.SaleService;
import com.scau.clothes.stock.model.dto.ClothesNormDto;
import com.scau.clothes.stock.model.entity.ClothesNorm;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@RequestMapping("/saleClothes")
@RestController
public class SaleClothesController {
    @Autowired
    private SaleClothesService saleClothesService;

    @PostMapping("/updateSaleClothes")
    @ApiOperation("修改订单明细信息")
    public AjaxResult updateSaleClothes(@RequestBody SaleClothes saleClothes) {
        int rows = saleClothesService.updateSaleClothes(saleClothes);
        return rows > 0 ? AjaxResult.success("修改订单明细信息成功") : AjaxResult.error("修改订单明细信息失败");
    }

    @PostMapping("/deleteSaleClothes")
    @ApiOperation("删除订单明细")
    public AjaxResult deleteClothesNorm(@RequestBody SaleClothes saleClothes) {
        int rows = saleClothesService.deleteSaleClothes(saleClothes);
        return rows > 0 ? AjaxResult.success("删除订单明细成功") : AjaxResult.error("删除订单明细失败");
    }

    @ApiOperation("年度销售额")
    @GetMapping("/yearPie")
    public AjaxResult yearPie(@RequestParam int year) {
        return AjaxResult.success(saleClothesService.getYearSales(year));
    }
    @ApiOperation("时间段各类销售额")
    @GetMapping("/timePie")
    public AjaxResult timePie(@RequestParam ("startDate")String startDate , @RequestParam("endDate") String endDate) {
        return AjaxResult.success(saleClothesService.selectSaleItemList(startDate,endDate));
    }


}
